<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.timepicker.addon.css" rel="stylesheet" />
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.mselect.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.timepicker.addon.js"></script>
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.multiselect.js"></script>
<script type="text/javascript">
get_check = function(){
	var ids = '';
	$("#list").find("input[type='checkbox']").each(function(){
		if ($(this).is(":checked"))
		{
			if (ids)
			{
				ids += ',';
			}
			ids += $(this).val();
		}
	});
	return ids;
};
$(function(){
	$(".datepicker").datetimepicker({dateFormat:'yy-mm-dd',changeMonth:true, timeFormat: 'HH:mm'});
	$("#multiselect").multiselect({height: 260, minWidth: 160});
	$("#check_all").click(function(){
		if ($(this).is(":checked"))
		{
			$(".list_table input[type='checkbox']").attr("checked", true);
		}
		else
		{
			$(".list_table input[type='checkbox']").attr("checked", false);
		}
	});
	$("#finish_btn").click(function(){
		var ids = get_check();
		if( ! ids)
		{
			alert('请选择编号！')
			return false;
		}
		if ( ! confirm('确定标记完成？'))
		{
			return false;
		}
		window.location.href=("<?=url('Setting::Log/MarkStatusCompleted')?>&ids=" + ids);
		});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<?include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>系统时间</th>
	<td>
		<input type="text" class="datepicker" name="begin_box_time" value="<?=isset($_GET['begin_box_time']) ? $_GET['begin_box_time'] : ''?>" /> to
		<input type="text" class="datepicker" name="end_box_time" value="<?=isset($_GET['end_box_time']) ? $_GET['end_box_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>执行时间</th>
	<td>
		<input type="text" class="datepicker" name="begin_execute_time" value="<?=isset($_GET['begin_execute_time']) ? $_GET['begin_execute_time'] : ''?>" /> to
		<input type="text" class="datepicker" name="end_execute_time" value="<?=isset($_GET['end_execute_time']) ? $_GET['end_execute_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>API名称</th>
	<td><input type="text" name="api_name" value="<?=isset($_GET['api_name']) ? $_GET['api_name'] : ''?>" /></td>
</tr>
<tr>
	<th>执行人</th>
	<td>
		<select name="user_id[]" multiple="multiple" id="multiselect">
		<?foreach ($users as $u):?>
		<option value="<?=$u['id']?>" <?if (isset($_GET['user_id']) && is_array($_GET['user_id']) && in_array($u['id'], $_GET['user_id'])) echo "selected='selected'"?>><?=$u['name']?></option>
		<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>执行状态</th>
	<td>
	<?foreach (Q::ini('custom_flag/ebay_api_call_log_status') as $s):?>
	<label><input type="checkbox" name="status[<?=$s['value']?>]" value="<?=$s['value']?>" <?if(isset($_GET['status']) && array_key_exists($s['value'], $_GET['status'])) echo "checked='checked'"?> /> <?=$s['name']?></label>
	<?endforeach;?>
	</td>
</tr>
<tr>
	<th></th>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<table width="100%" class="list_table" id="list">
<tr>
	<th width="90">编号</th>
	<th width="200">API名称</th>
	<th width="60">执行状态</th>
	<th width="50">执行人</th>
	<th width="70">所需时间(s)</th>
	<th width="50">ACK</th>
	<th width="">返回提示</th>
	<th width="130">系统时间</th>
	<th width="130">执行时间</th>
	<th width="60">日志文件</th>
</tr>
<?foreach ($ebay_api_call_log_lists as $eacll):?>
<tr>
	<td><label><input type="checkbox" value="<?=$eacll['id']?>" /> <?=$eacll['id']?></label></td>
	<td><?=$eacll['api_name']?></td>
	<td><?=Helper_BSS_Normal::getIniOne('ebay_api_call_log_status','value', $eacll['status'], 'name')?></td>
	<td><?=$eacll['execute_user_name']?></td>
	<td><?=$eacll['execute_microtime']?></td>
	<td><?=$eacll['ack']?></td>
	<td><?=$eacll['message']?></td>
	<td><?=$eacll['box_time']?></td>
	<td><?=$eacll['execute_time']?></td>
	<?if ($eacll['status'] == Q::ini('custom_flag/ebay_api_call_log_status/completed/value') && $eacll['filename']):?>
	<td><a href="<?=url('Setting::Log/EbayApiCallLogFile', array('filename' => $eacll['filename']))?>" title="<?=$eacll['filename']?>" target="_blank">查看</a></td>
	<?else:?>
	<td><font color="#aaaaaa">查看</font></td>
	<?endif;?>
</tr>
<?endforeach;?>
</table>
<?=$page?>
<table class="list_table">
<tr>
<td rowspan="5"><label><input type="checkbox" id="check_all" /> 全选</label></td>
<td><input type="button" class="button" value="标记完成" id="finish_btn" /></td>
</tr>
</table>
<?php $this->_endblock();?>